 package srdb.migration;
 
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
 
 public class CLParser
 {
   private Hashtable optionsList = new Hashtable();
   private Vector paramsList = new Vector();
   private int optionIndex = 0;
   private int paramIndex = 0;
 
   public boolean parseArgs(String[] args)
   {
     String optName = null;
     String optValue = null;
     boolean invalidArgs = false;
 
     for (int i = 0; i < args.length; i++) {
       if (args[i].startsWith("--")) {
         invalidArgs = true;
         break;
       }if (args[i].startsWith("-")) {
         optName = args[i].substring(1);
         this.optionsList.put(optName.toLowerCase(), "");
       }
       else
       {
         if (optName == null) {
           if (i >= args.length - 1) break;
           invalidArgs = true; break;
         }
 
         this.optionsList.put(optName.toLowerCase(), args[i]);
         optName = null;
       }
     }
 
     return !invalidArgs;
   }
 
   public boolean hasOption(String optName) {
     return this.optionsList.containsKey(optName.toLowerCase());
   }
 
   public String getOption(String optName) {
     return (String)this.optionsList.get(optName.toLowerCase());
   }
 
   public String nextOption(String optName) {
     return (String)this.optionsList.get(optName.toLowerCase());
   }
 
   public Enumeration getOptionNames() {
     return this.optionsList.keys();
   }
   public String nextParam() {
     if (this.paramIndex < this.paramsList.size()) {
       return (String)this.paramsList.elementAt(this.paramIndex++);
     }
     return null;
   }

   @Override
   public String toString() {
     return "CLParser{" +
             "optionsList=" + optionsList +
             ", paramsList=" + paramsList +
             ", optionIndex=" + optionIndex +
             ", paramIndex=" + paramIndex +
             '}';
   }
 }

/* 

 * 
 */